﻿using Hxj.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Utility.Helper
{
    public class DbHelper
    {
        private static DbSession DefaultDb;
        /// <summary>
        /// 得到数据库对象
        /// </summary>
        /// <returns></returns>
        public static DbSession GetDatabase()
        {
            return GetDatabase("sqlConn");
        }
        /// <summary>
        /// 得到数据库对象
        /// </summary>
        /// <returns></returns>
        public static DbSession GetDatabase(string connConfigName)
        {
            try
            {
                if (DefaultDb == null)
                {
                    DefaultDb = new DbSession(connConfigName);  //默认连接
                }
            }
            catch (Exception ex)
            {
                throw new Exception("获取数据库连接出现异常:" + ex.Message);
            }
            return DefaultDb;
        }
    }
}
